home *** CD-ROM | disk | FTP | other *** search
/ Celestin Apprentice 5 / Apprentice-Release5.iso / Source Code / C / Frameworks / Grant's CGI Framework 1.0b14 / Interface / ErrorInt.c < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-08  |  2.4 KB  |  95 lines  |  [TEXT/CWIE]

  1. /*****
  2.  *
  3.  *    ErrorInt.c
  4.  *
  5.  *    This is a support file for "Grant's CGI Framework".
  6.  *    Please see the license agreement that accompanies the distribution package
  7.  *    for licensing details.
  8.  *
  9.  *    Copyright ©1995,1996 by Grant Neufeld
  10.  *    grant@acm.com
  11.  *    http://arpp.carleton.ca/grant/
  12.  *
  13.  *****/
  14.  
  15. #include "MyConfiguration.h"
  16. #if kCompileWithForeground
  17.  
  18. #include "compiler_stuff.h"
  19.  
  20. #include "DebugUtil.h"
  21. #include "DialogFunc.h"
  22. #include "MemoryUtil.h"
  23.  
  24. #include "ErrorInt.h"
  25.  
  26.  
  27. /***  FUNCTIONS  ***/
  28.  
  29. /** Report System Errors **/
  30.  
  31. /* Display a system error alert with the given string. */
  32. void
  33. ErrorAlertSystemString (
  34.     OSErr            errNum,
  35.     StringHandle    errStrHdl,
  36.     Str255 *        errNameStrPtr
  37.     )
  38. {
  39.     Str255            errNumStr;    /* used for string version of the error number */
  40.     short            alertItem;
  41.     
  42.     my_assert ( (errStrHdl != NULL) && (*errStrHdl != NULL),
  43.         "\pErrorIntSystemString: null error string" );
  44.     
  45.     /* Create a pascal format string of the error number. */
  46.     NumToString ( errNum, errNumStr );
  47.     
  48.     my_assert ( (HGetState((Handle)errStrHdl) & kMemoryHandleLockedFlag) == nil,
  49.         "\pErrorAlertSystemString: errStrHdl is already locked!" );
  50.     HLockHi ( (Handle)errStrHdl );
  51.     
  52.     if ( errNameStrPtr == NULL )
  53.     {
  54.         /* Set the dialog to display the string and error number strings. */
  55.         ParamText ( *((Str255 *)errStrHdl), errNumStr, NULL, NULL );
  56.     }
  57.     else
  58.     {
  59.         /* Set the dialog to display the string and error number strings. */
  60.         ParamText ( *((Str255 *)errStrHdl), errNumStr, *errNameStrPtr, NULL );
  61.     }
  62.     
  63.     /* Display the alert. */
  64.     alertItem = StopAlert ( krErrorDialogSystem, NewModalFilterProc(defaultAlert1ButtonEventFilter) );
  65.     
  66.     HUnlock ( (Handle)errStrHdl );
  67. } /* ErrorAlertSystemString */
  68.  
  69.  
  70. /** Report Startup Errors **/
  71.  
  72. #pragma segment Startup
  73. /* Display a startup error alert with the given string. */
  74. void
  75. ErrorAlertStartupString ( short errNum, Str255 *errStrHdl )
  76. {
  77.     Str255        errNumStr;    /* used for string version of the error number */
  78.     short        alertItem;
  79.     
  80.     /* Create a pascal format string of the error number. */
  81.     NumToString ( errNum, errNumStr );
  82.     
  83.     /* Set the dialog to display the string and error number strings. */
  84.     ParamText ( *errStrHdl, errNumStr, NULL, NULL );
  85.     
  86.     /* Display the alert. */
  87.     alertItem = StopAlert ( krErrorDialogStartup, NewModalFilterProc(defaultAlert1ButtonEventFilter) );
  88. } /* ErrorAlertStartupString */
  89. #pragma segment Main
  90.  
  91.  
  92. #endif    /* kCompileWithForeground */
  93.  
  94. /*****  EOF  *****/
  95.